<template>
  <div>
    <div class="m_contentBox">
      <a-card :bordered="false">
        <div class="m_aCardBox">
          <!-- 查询区域 -->
          <div class="tabBox">
            <div class="table-page-search-wrapper">
              <a-form layout="inline" @keyup.enter.native="searchQuery">
                <a-row :gutter="24">
                  <a-col :span="6">
                    <a-form-item label="关键词">
                      <a-input placeholder="请输入" v-model="queryParam.name" allowClear></a-input>
                    </a-form-item>
                  </a-col>
                  <span style="float: right; overflow: hidden" class="table-page-search-submitButtons">
                    <a-col :span="6">
                      <a-button type="primary" @click="searchQuery()">查询</a-button>
                      <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
                    </a-col>
                  </span>
                </a-row>
              </a-form>
            </div>
          </div>
          <!-- 查询区域-END -->

          <!-- 操作按钮区域 -->

          <!-- table区域-begin -->
          <div class="cardBox">
            <a-button class="m_mb24" @click="handleAdd" type="primary" icon="plus">新增标准</a-button>
            <a-table ref="table" size="middle" :scroll="{ x: true }" bordered rowKey="id" :columns="columns"
                     :dataSource="dataSource" :pagination="ipagination" :loading="loading" class="j-table-force-nowrap"
                     @change="handleTableChange">
              <span slot="action" slot-scope="text, record">
                <a @click="handleEdit(record)">编辑</a>
                <a-divider type="vertical"/>
                <a-popconfirm title="确定删除?" ok-text="确定" cancel-text="取消" @confirm="handleDelete(record)">
                  <a>删除</a>
                </a-popconfirm>
              </span>
            </a-table>
          </div>

          <add-modal ref="modalForm" @ok="modalFormOk"></add-modal>
        </div>
      </a-card>
    </div>
  </div>
</template>

<script>
import "@/assets/less/TableExpand.less";
import {mixinDevice} from "@/utils/mixin";
import {JeecgListMixin} from "@/mixins/JeecgListMixin";
import addModal from "./modules/addModal.vue";

export default {
  name: "CyEmissionFactorDataList",
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    addModal,
  },
  data() {
    return {
      description: "碳排因子数据详情管理页面",
      // 表头
      columns: [
        {
          title: "序号",
          dataIndex: "",
          key: "rowIndex",
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          },
        },
        {
          title: "核算标准1",
          align: "center",
          dataIndex: "mainStandardName",
        },
        {
          title: "核算标准2",
          align: "center",
          dataIndex: "convertStandardName",
        },
        {
          title: "操作",
          dataIndex: "action",
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: {customRender: "action"},
        },
      ],
      url: {
        list: "/orgCarbonStandardConversion/getPageList",
        delete: "/orgCarbonStandardConversion/removeFromAdmin",
        deleteBatch: "/emission/factor/cyEmissionFactorData/deleteBatch",
        exportXlsUrl: "/emission/factor/cyEmissionFactorData/exportXls",
      },
      dictOptions: {},
      superFieldList: [],
    };
  },
  created() {
  },
  mounted() {
  },
  computed: {},
  methods: {
    initDictConfig() {
    },
    modalFormOk() {
      this.searchQuery();
    },
    handleDelete(record) {
      this.$http.get(this.url.delete + '?id=' + record.id).then(res => {
        if (res.success) {
          this.$message.success("删除成功");
          this.searchQuery();
        }
      })
    },
    handleEdit(record) {
      console.log(record);

      this.$refs.modalForm.edit(record.id);
    },
  },
};
</script>
<style lang="less" scoped>
@import "~@assets/less/common.less";

/deep/ .ant-card-body {
  background: #F5F8F7;
}

.tabBox {
  padding: 24px 24px 0;
  background: #FFFFFF;
  border-radius: 3px;
}

.cardBox {
  margin-top: 24px;
  padding: 24px;
  background: #FFFFFF;
  border-radius: 3px;
}
</style>
